<?php   // $Id: bon_delete.php 289 2008-10-05 17:05:19Z pcoustillas $ ?>
<?php
/*
Copyright (C) 2003-2004 Guy Hendrickx
Licensed under the terms of the GNU  General Public License:http://www.opensource.org/licenses/gpl-license.php
File Authors:Guy Hendrickx 
*/
require_once("include/verif.php");
require_once("include/config/common.php");
require_once("include/config/var.php");
require_once("include/language/$lang.php");

$num_bon=isset($_GET['num_bon'])?$_GET['num_bon']:"";

$sql = "SELECT num_facture FROM ${tblpref}bon_comm WHERE num_bon=$num_bon";
$req = mysql_query($sql) or die("Erreur SQL !<br/>$sql<br/>" . mysql_error());
$data = mysql_fetch_array($req);

$num_facture = $data['num_facture'];

if($num_facture!=0)
{
	header("Location: bon_lister.php?message=$lang_err_efa_bon");
	exit;
} else {
	mysql_select_db($db) or die ("Could not select $db database");
	$sql1 = "DELETE FROM ${tblpref}bon_comm WHERE num_bon='$num_bon'";
	mysql_query($sql1) or die('Erreur SQL !<br>'.$sql1.'<br>'.mysql_error());
	$sql2 = "DELETE FROM ${tblpref}cont_bon WHERE bon_num='$num_bon'";
	mysql_query($sql2) or die("Erreur suppression contenu devis !<br/>$sql2<br/>" . mysql_error());
}

header("Location: bon_lister.php?message=Bon n°$num_bon supprimé avec succès.");

?>
